package scope;

import java.util.Hashtable;
import java.util.Vector;
import utility.ConvertToLower;


import dbmanager.DBManager;
import dbmanager.GetIdName;

public class Private implements Scope
{
	DBManager database;
	GetIdName gid;
	private  String PRIVATE="private";
	Vector<Object> scopeVector = new Vector<Object>();
	public Vector<Object> getVector() 
	{
		
		return scopeVector;
	}

	public void setDbmanger(DBManager database) 
	{
	
		this.database = database;
		gid = new GetIdName(database);
		PRIVATE = gid.getId(PRIVATE);
	}

	public void setVector(Vector<Object> scopeVector) 
	{
	
		this.scopeVector = scopeVector;
	}

	public void processScope() 
	{
		Vector<Object>tempvector = new Vector<Object>();
		tempvector.addAll(scopeVector);
		for(int i=0;i<scopeVector.size();i++)
		{	
			Hashtable<Object, Object>table =(Hashtable<Object, Object>) scopeVector.get(i);
			table = ConvertToLower.convertHashKey(table);
			if(table.get("pv").toString().equals(PRIVATE))
			{	
				String privatemember  = table.get("ref").toString();
				tempvector.remove(i);
				int index=-1;
				for(int j=0;j<tempvector.size();j++)
				{
					Hashtable<Object, Object>temptable =(Hashtable<Object, Object>) tempvector.get(j);
					if(temptable.get("pid").equals(privatemember))
					{
						index = j;
						break;
					}	
				}
				try
				{
					tempvector.remove(index);
				}
				catch (Exception e) 
				{
					e.printStackTrace();
				} 
				
			}	
		}
		scopeVector.clear();
		scopeVector.addAll(tempvector); 
	}
	

	public void getParent(String parentobject) 
	{
		
	}

}
